<template>
<div>
  <h3>考试名单</h3>

  <el-card class="box-card">
    <el-row :gutter="20">
      <el-col :span="7">
        <el-input placeholder="请输入内容"
                  v-model="quertInfo.searchText" clearable
                  @clear="getfirstgradelist">
          <el-button slot="append" icon="el-icon-search"
                     @click="getfirstgradelist">
          </el-button>
        </el-input>
      </el-col>
      <el-col :span="4">
        <el-button type="primary" @click="addDialogVisable = true">添加学生</el-button>
      </el-col>
    </el-row>

    <el-table :data = firstgradeList>
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column label="考号" prop="ENo"></el-table-column>
      <el-table-column label="政治成绩" prop="PoliticeGrade"></el-table-column>
      <el-table-column label="外语成绩" prop="FlanguageGrade"></el-table-column>
      <el-table-column label="专业成绩" prop="BProfessionalGrade"></el-table-column>
      <el-table-column label="操作" width="200px">
        <!--修改按钮-->
        <template slot-scope="scope">
          <el-button type="primary" icon="el-icon-edit" size="mini"
                     >修改</el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>

  <el-dialog
    title="添加学生"
    :visible.sync="addDialogVisable"
    width="50%" @close="addDialogClosed">
    <el-form :model="addForm"  ref="addFormRed" label-width="100px" >
      <el-form-item label="考号" prop="ENo">
        <el-input v-model="addForm.ENo"></el-input>
      </el-form-item>

      <el-form-item label="政治成绩" prop="PoliticeGrade">
        <el-input v-model="addForm.PoliticeGrade"></el-input>
      </el-form-item>

      <el-form-item label="外语成绩" prop="FlanguageGrade">
        <el-input v-model="addForm.FlanguageGrade"></el-input>
      </el-form-item>

      <el-form-item label="专业成绩" prop="BProfessionalGrade">
        <el-input v-model="addForm.BProfessionalGrade"></el-input>
      </el-form-item>

    </el-form>
    <span slot="footer" class="dialog-footer">
    <el-button @click="addDialogVisable = false">取 消</el-button>
    <el-button type="primary" @click="addFirstgrade">确 定</el-button>
  </span>
  </el-dialog>


</div>
</template>



<script>
export default {
  data() {
    return {
      quertInfo: {
        searchText: '',
        page: 1,
        //当前每页显示多少条数据
        limit: 50
      },
      firstgradeList: [],
      total: 0,
      addDialogVisable:false,

      addForm:{
        ENo: '',
        PoliticeGrade: '',
        FlanguageGrade: '',
        BProfessionalGrade: ''
      },
      editdialogVisible: false,
      editForm: {

      }
    }
  },

  created() {
    this.getfirstgradelist()
  },

  methods:{
    addDialogClosed() {
      this.$refs.addFormRed.resetFields()
    },
    //添加学生成绩
    addFirstgrade() {
      this.$http.post('firstgrade', this.addForm)
      this.$message.success('添加成功')
      this.addDialogVisable = false
      this.getfirstgradelist()
    },

    async getfirstgradelist() {
      const {data: res} = await this.$http.get('firstgrade', {params: this.quertInfo})
      this.total = res.data.total
      this.firstgradeList = res.data.value
      console.log(res)
    },
  }
}
</script>

<style lang ="less" scoped>
</style>
